/**
 * 
 */
package oldtrigger;

import java.util.ArrayList;
import java.util.Scanner;


/**
 * @author Philip
 *
 */
public class TextResponseTrigger extends AbstractTrigger {
	protected String[] response;
	protected int lines;
	
	public TextResponseTrigger(String trigger, String response) {
		super(trigger);
		lines = 1;
		
		
		for (int i = 0; i < response.length(); i++) {
			if (response.charAt(i) == '\n') {
				lines++;
			}
		}
		
		if (response.isEmpty()) {
			response += "\n";
		}
		
		this.response = new String[lines];
		Scanner scan = new Scanner(response);
		for (int i = 0; i < lines; i++) {
			this.response[i] = scan.nextLine();
		}
		
		scan.close();
	}

	public boolean triggers(String text) {
		return true;
	}
	
	public String getResponse() {
		return response[0];
	}
	
	@Override
	public String getResponse(int line) {
		return response[line];
	}
	
	public int compareTo(AbstractTrigger other) {
		return trigger.compareTo(other.trigger);
	}

	@Override
	public int linesInResponse() {
		return lines;
	}
}
